package utils

import (
	"context"
	"fmt"
	"os/exec"
)

func RunCommandInDir(ctx context.Context, dir, command string, args ...string) error {
	cmd := exec.CommandContext(ctx, command, args...)
	cmd.Dir = dir // 设置命令的工作目录
	output, err := cmd.CombinedOutput()
	if err != nil {
		return fmt.Errorf("命令执行失败: %v, 输出: %s", err, output)
	}
	fmt.Printf("目录: %s\n输出:\n%s\n", dir, output)
	return nil
}
